
<input type="hidden" name='url' id='url' value="<?php echo $this->Html->url( null, true ); ?>">
<div class="row"> 
	<div class="col-sm-12 col-md-12">
		<div class="page-header">
		  <h1>Servicios</h1>
		</div>

		<div class="row">
			<div class="col-md-6">							
				<div class="btn-group pull-left">
					<?php echo $this->Html->link(__('Nuevo', true), array('controller' => 'services', 'action' => 'add' ),array('class'=>'btn btn-default ')); ?> 				  
				    <a href="#" class="btn btn-default " id='edit_bt'>Editar</a>
				</div>
			</div>

			<div class="col-md-6 ">	
				<form method='post' >
					<div class="input-group">
		      	<input type="text" name='keyword'  class="form-control" placeholder='Filtro Servicio'>
		      	<span class="input-group-btn">
		        	<button class="btn btn-default" type="button">Buscar</button>
		      	</span>
				  </div>
				</form>				
			</div>
		</div>
			
			<br>
			<br>
			
				
			<table class="table table-hover table-striped table-bordered">
				<thead>
					<tr>
						<th>#</th>
						<th><?php echo $this->Paginator->sort('service_code', 'Código'); ?></th>
						<th><?php echo $this->Paginator->sort('name', 'Nombre'); ?></th>
						<th><?php echo $this->Paginator->sort('Category.name', 'Categoria'); ?></th>
						<th><?php echo $this->Paginator->sort('Zone.name', 'Zona'); ?></th>
						<th><?php echo $this->Paginator->sort('time', 'Duracíon (min)'); ?></th>
						<th><?php echo $this->Paginator->sort('sessions', 'Sesiones'); ?></th>
						<th><?php echo $this->Paginator->sort('price', 'Precio'); ?></th>
						<!-- <th>Action</th> -->
					</tr>
				</thead>
				<tbody>
					<?php foreach ($data as $item) :?>
						<tr>
							<td><input type="checkbox" name='client_ids[]' value="<?php echo $item['Services']['id']?>"></td>
							<td><?php echo $item['Services']['service_code']?></td>
							<td><?php echo $item['Services']['name']?></td>
							<td><?php echo $item['Category']['name']?></td>
							<td><?php echo $item['Zone']['name']?></td>
							<td><?php echo $item['Services']['time']?></td>
							<td><?php echo $item['Services']['sessions']?></td>
							<td><?php echo $item['Services']['price']?> $ </td>
							
							
							<!--<td>
								<button type="button" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-eye-open"></i>View</button>
								<button type="button" class="btn btn-xs btn-success"><i class="glyphicon glyphicon-pencil"></i>Edit</button>
								<button type="button" class="btn btn-xs btn-danger"><i class="glyphicon glyphicon-remove"></i>Delete</button>
								
							</td> -->
						</tr>
					<?php endforeach;?>	
				</tbody>
			</table>
		  <ul class="pagination">
		        <?php 
		            echo $this->Paginator->prev( '<<', array( 'class' => '', 'tag' => 'li' ), null, array( 'class' => 'disabled', 'tag' => 'li' ) );
		            echo $this->Paginator->numbers( array( 'tag' => 'li', 'separator' => '', 'currentClass' => 'active', 'currentTag' => 'a' ) );
		            echo $this->Paginator->next( '>>', array( 'class' => '', 'tag' => 'li' ), null, array( 'class' => 'disabled', 'tag' => 'li' ) );
		        ?>
	    </ul>


		
	</div> 
</div>

<script type="text/javascript">
	function get_check_id(){
	    var result=0;
	  //users_ids
	    $('input[name=client_ids\\[\\]]').each(function() {
	        if( $(this).is(":checked")){
	            var user_id = $(this).val();	           
	            result =  user_id;
	        }
	    });
	    return result;
	}
$(function(){
	var url=$("#url").val();
	//console.debug("URL: %o",url);
	$("#edit_bt").click(function(){
		chck_id= get_check_id();
		redirect_url=url+"/edit/"+chck_id
		//console.debug("redirect_url: %o",redirect_url);
		window.location.replace(redirect_url);
		return false;
	});
	$("#history_bt").click(function(){
		chck_id= get_check_id();
		redirect_url=url+"/history/"+chck_id
		//console.debug("redirect_url: %o",redirect_url);
		window.location.replace(redirect_url);
		return false;
	});
});
</script>

